dnl vim: set sw=8 sts=8 noet :

AC_INIT([limshsql], [2.0], [dcortarello@gmail.com])
AC_PREREQ(2.5)
AM_INIT_AUTOMAKE(1.9)
AM_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --silent"
AC_PROG_CC
AC_CONFIG_HEADER(config.h)
AC_PROG_CC_C_O
dnl check for required programs
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_C_BIGENDIAN
AC_C_INLINE
AC_CHECK_SIZEOF(int, 32)
dnl check for required headers
AC_CHECK_HEADER(stdio.h)
AC_CHECK_HEADER(stdlib.h)
AC_CHECK_HEADER(unistd.h)
AC_CHECK_HEADER(string.h)
AC_CHECK_HEADER(signal.h)
AC_CHECK_HEADER(time.h)
AC_CHECK_HEADER(pwd.h)
AC_CHECK_HEADER(sys/types.h)
dnl check for required libraries
AC_CHECK_LIB(ncurses,initscr,, [echo "ncurses not found" &&exit 1])

AM_CONDITIONAL(BUILD_MYSQL, true)
AC_ARG_ENABLE(mysql, [  --enable-mysql          enable MySQL support], [
	AM_CONDITIONAL(BUILD_MYSQL, true)
	BUILD_MYSQL=true
	AC_SUBST(BUILD_MYSQL)
])

if test -n "$BUILD_MYSQL"; then
	AC_CHECK_HEADERS([mysql/mysql.h],[MYSQL_LIBS=-lmysqlclient],[AC_MSG_ERROR("mysql headers missing.")])
	AC_CHECK_LIB(mysqlclient, main,[],,[AC_MSG_ERROR("mysql headers missing.")])
	AC_SUBST(MYSQL_LIBS)
fi

dnl output
AC_OUTPUT(
	Makefile
	src/Makefile
	)
